package com.train.daily.facade.web;

import cn.hutool.core.bean.BeanUtil;
import com.train.common.group.QueryGroup;
import com.train.common.resp.CommonResp;
import com.train.common.resp.PageResp;
import com.train.daily.dto.ticket.DailyTrainTicketPageDTO;
import com.train.daily.req.ticket.DailyTrainTicketPageReq;
import com.train.daily.resp.ticket.DailyTrainTicketPageResp;
import com.train.daily.service.DailyTrainTicketService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * dailyTrainTicket Facade 实现类
 * @author baitiaojun
 * @createDate 2025-03-07 00:09:31
 */
@RestController("webDailyTrainTicketFacade")
@RequiredArgsConstructor
@RequestMapping("train-ticket")
public class DailyTrainTicketFacade {

    private final DailyTrainTicketService dailyTrainTicketService;

    @PostMapping("page")
    public CommonResp pageList(@RequestBody @Validated(QueryGroup.class) DailyTrainTicketPageReq req) {
        DailyTrainTicketPageDTO dailyTrainTicketPageDTO = BeanUtil.copyProperties(req, DailyTrainTicketPageDTO.class);
        PageResp<DailyTrainTicketPageResp> pageResp = dailyTrainTicketService.pageList(dailyTrainTicketPageDTO);
        return CommonResp.ok(pageResp);
    }
}
